package cn.com.oceansoft.modules.order.controller;

import cn.com.oceansoft.application.common.util.HttpClientUtil;
import cn.com.oceansoft.application.constant.ConfigInfo;
import cn.com.oceansoft.framework.kits.ApiResult;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import static org.springframework.web.bind.annotation.RequestMethod.GET;

/**
 * Created by CS on 2016/10/6.
 * Update by zhul on 2016/11/04
 */
@Controller
@RequestMapping("order")
public class OrderController {

    @Resource
    protected ConfigInfo configInfo;

    /**
     * 预约中心
     *
     * @param request
     * @return
     */
    @RequestMapping(value = {"index", ""})
    public String index(HttpServletRequest request) {
        return "order/index";
    }

    /**
     * 应用中心-失物招领列表
     *
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "page", method = GET)
    public Object page(HttpServletRequest request) {

        ApiResult apiResult = null;
        String ps = request.getParameter("ps");
        String pi = request.getParameter("pi");
        String addid = request.getParameter("addid");
        String deptid = request.getParameter("deptid");


        String result = HttpClientUtil.doGet(configInfo.getMsHostUrl() + "order/page",
                "ps", ps,
                "pi", pi,
                "addid", addid,
                "deptid", deptid
        );

        apiResult = JSONObject.parseObject(result, ApiResult.class);
        return apiResult;
    }
}
